package com.gateway.jug.gps;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.gateway.jug.R;

public class FuzzControl extends Activity implements View.OnClickListener {

	private static final int ACTIVITY_LOCATION = 0;
	private static final int ACTIVITY_FUZZ_STATISTICS = 1;
	
	private Button foundFuzzButton;
	private Button locationButton;
	private Button statisticsButton;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.controlpanel);
		
		foundFuzzButton = (Button) findViewById(R.id.fuzz);
		locationButton = (Button) findViewById(R.id.map);
		statisticsButton = (Button) findViewById(R.id.statistics);
		
		foundFuzzButton.setOnClickListener(this);
		locationButton.setOnClickListener(this);
		statisticsButton.setOnClickListener(this);

		startService(new Intent("com.gateway.jug.interfaces.REMOTE_SERVICE"));
    }

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
        stopService(new Intent("com.gateway.jug.interfaces.REMOTE_SERVICE"));
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		// TODO Auto-generated method stub
		super.onSaveInstanceState(outState);
	}

	@Override
	public void onClick(View v) {
		if (v == foundFuzzButton) {
			// TODO - come back and make this a distributed call.
	        Toast.makeText(FuzzControl.this, com.gateway.jug.R.string.fuzz_location_recorded, Toast.LENGTH_SHORT).show();			
		} else if (v == locationButton) {
			Intent mapIntent = new Intent(FuzzControl.this, FuzzMinder.class);
			startActivityForResult(mapIntent, ACTIVITY_LOCATION);			
		} else if (v == statisticsButton) {
			// TODO Auto-generated method stub
			Intent statsIntent = new Intent(FuzzControl.this, FuzzStats.class);
			startActivityForResult(statsIntent, ACTIVITY_FUZZ_STATISTICS);
		}
	}

}
